// 示例方法，没有实际意义
export function trim(str: string) {
  return str.trim();
}


export function formatBytes(bytes: number, decimals = 2) {
  if (bytes === 0) return '0 Bytes';

  const k = 1024;
  const dm = decimals < 0 ? 0 : decimals;
  const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];

  const i = Math.floor(Math.log(bytes) / Math.log(k));

  return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
}

export function formatDate(timestamp: number) {
  let date = new Date(timestamp)
  return `${date.getFullYear()}年${date.getMonth()}月${date.getDate()}日 ${date.getHours()}:${date.getMinutes()}`
}

export function formattingTime(count: number) {
  var time = '';
  var second = count % 60;
  var minute = count / 60 % 60;
  time = second + "秒";
  if (minute >= 1) {
    time = minute.toFixed(0) + "分" + second + "秒";
  }
  var hour = count / 60 / 60 % 24;
  if (hour >= 1) {
    time = hour.toFixed(0) + "小时" + minute.toFixed(0) + "分" + second + "秒";
  }
  var day = count / 60 / 60 / 24;
  if (day >= 1) {
    time = day.toFixed(0) + "天" + hour.toFixed(0) + "小时" + minute.toFixed(0) + "分" + second + "秒";
  }
  return time
}